package com.m3958.firstgwt.client.constants;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.JsArray;
import com.m3958.gwtutil.clientside.client.jso.MenuitemJso;

public class AppMenuAndCat {

	
	private String[] catKeyList = new String[]{"articleCat","xinjianCat","voteCat","assetCat","siteCat","userCat","othersCat","systemCat"};
	
	private Map<String,List<String>> menuListMap = new HashMap<String, List<String>>();
	
	
	public AppMenuAndCat(){
	}
	
	
	public void initMe(JsArray<MenuitemJso> menuitems){
		for(int i=0;i<menuitems.length();i++){
			MenuitemJso mij =menuitems.get(i); 
			addtoMenuListMap(mij.getMenuItemCat(),mij.getUniqueName());
		}
	}
	
	private void addtoMenuListMap(String catKey,String menuKey){
		if(menuListMap.get(catKey) == null){
			menuListMap.put(catKey, new ArrayList<String>());
		}
		menuListMap.get(catKey).add(menuKey);
	}
	
	public List<String> getSubMenuItems(String catKey){
		return menuListMap.get(catKey);
	}

	public String[] getCatKeyList() {
		return catKeyList;
	}
}
